package com.facebookproject;

import java.util.ArrayList;
import java.util.List;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import com.facebookproject.getsuggestitems.Item;
import com.facebookproject.getsuggestitems.ItemAdapter;
import com.facebookproject.graph.GraphSearchActivity;
import com.facebookproject.graph.showdialogdetail.ShowDialog;

public class FragmentMe extends ListFragment{

	ItemAdapter adapter;
	List<Item> myListItems = new ArrayList<Item>();
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){

		adapter = new ItemAdapter(getActivity(), R.layout.item, myListItems);
		setListAdapter(adapter);

		return inflater.inflate(R.layout.fragment_me, null);
	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		myListItems.clear();
		myListItems.add(new Item("me_aboutme", "About me"));
		myListItems.add(new Item("me_album3", "Album"));
		myListItems.add(new Item("me_favourites", "Likes"));
		myListItems.add(new Item("me_event", "Events"));	
		myListItems.add(new Item("me_musicilike", "Music I like"));	
		myListItems.add(new Item("me_movieilike", "Movie I like"));
		myListItems.add(new Item("me_gameilike", "Game I like"));
		myListItems.add(new Item("me_bookilike", "Book I like"));
		myListItems.add(new Item("me_tv", "Tv show I like"));
		myListItems.add(new Item("me_photoilike", "Photos I have liked"));
		myListItems.add(new Item("me_postilike", "Post I have liked"));

		super.onActivityCreated(savedInstanceState);
	}
	@Override
	public void onListItemClick(ListView l, View v, int position, long id) {
		position+=1;
		if(position==1){
			new ShowDialog("me",getActivity());
		}
		else{
			Intent intent = new Intent(getActivity(), GraphSearchActivity.class);
			intent.putExtra("type", position);
			intent.putExtra("tab", 1);
			startActivity(intent);
		}
		super.onListItemClick(l, v, position, id);
	}
	@Override
	public void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
	}
}
